package com.service.impl;

import com.mapper.SysMenuMapper;
import com.pojo.SystemMenu;
import com.service.SysMenuService;
import com.util.TreeUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
@Transactional
public class SysMenuServiceImpl implements SysMenuService {
    @Autowired
    private SysMenuMapper sysMenuMapper;
    @Override
    public Map<String, Object> menu(Integer empno) {
        Map<String, Object> map = new HashMap<String,Object>(16);
        Map<String,Object> home = new HashMap<String,Object>(16);
        Map<String,Object> logo = new HashMap<String,Object>(16);
        List<SystemMenu> menuList = sysMenuMapper.findAllByStatusOrderBySort(empno);
        home.put("title","首页");
        home.put("href","page/reception/sell.jsp");//控制器路由,自行定义
        logo.put("title","后台管理系统");
        logo.put("image","images/logo.png");//静态资源文件路径,可使用默认的logo.png
        map.put("homeInfo",home);
        map.put("logoInfo",logo);
        map.put("menuInfo",TreeUtil.toTree(menuList, 0));
        return map;
    }
}